<%--
    Document   : broadcastCheck.jsp
    Created on : 2010. 11. 14
    Author     : Jeffrey Ha

--%>

<%@page contentType="text/html" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="net.hekka.canyoutalk.data.vo.list.TempLogQueryVoList,
         net.hekka.canyoutalk.data.vo.TempLogQueryVo,
         net.hekka.canyoutalk.web.vo.PageVo,
         java.text.SimpleDateFormat;" %>
<HTML>
    <HEAD>
<!--        <meta http-equiv="refresh" content="20;">-->
        <title> CanYouTalk LogManager</title>
        <link rel="StyleSheet" type="text/css" href="./css/maincss.css" />
    </HEAD>

    <%
        HttpSession httpSession = request.getSession();
        TempLogQueryVoList tempLogQueryVoList = (TempLogQueryVoList) request.getAttribute("tempLogQueryVoList");
        TempLogQueryVoList friendStateList = (TempLogQueryVoList) request.getAttribute("friendStateList");

        int sequence01 = (String) request.getAttribute("sequence01") == null ? 0 : Integer.parseInt((String) request.getAttribute("sequence01"));
    %>

    <script language ="javascript">
        function closeWindow(){
            window.close();
        }
    </script>

    <body>
        <div id="wrapper">
            <div id="header" align="center">
                <h5> Broadcast Check </h5>
            </div>
<!--
            <div id="header" align="center">
                <h1> log data </h1>
            </div>

            <div id="header_menu">
                <ul>
                    <li><a href="./TempLogQueryServlet?serviceId=getNormalView&nowPage=1&queryCount=100">Normal View</a></li>
                    <li><a href="./TempLogQueryServlet?serviceId=getDetailView&nowPage=1&queryCount=100">Detail View</a></li>
                    <li><a href="./TempLogQueryServlet?serviceId=getStatusChangeList&nowPage=1&queryCount=20">Broadcast Check</a></li>
                </ul>
            </div>
-->


            <div id="content" align="center">

 <%
        if (tempLogQueryVoList != null && tempLogQueryVoList.size() > 0) {      // 0001
 %>
            <FORM id ="broadcastCheck" name="broadcastCheck" method="post" action ="" accept-charset="UTF-8">
                <input type="hidden" name="sequence" value ='<%=sequence01%>'>

                <table  border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
                    <tr>
                        <h5>The friends that are received my notification.</h5>
                    </tr>
                    
                    <tr>
                        <td nowrap width="40" 	bgcolor = "#336699" align="center"><font color="white">seq</font></td>
                        <td nowrap width="130" bgcolor = "#336699" align="center"><font color="white"> Owner </font></td>
                        <td nowrap width="130" bgcolor = "#336699" align="center"><font color="white"> Friend	</font></td>
                        <td nowrap width="40" 	bgcolor = "#336699" align="center"><font color="white"> Status 	</font></td>
                        <td nowrap width="40"  bgcolor = "#336699"	align="center"><font color="white"> Check Number </font></td>
                        <td nowrap width="200" bgcolor = "#336699" align="center"><font color="white"> Packet Data 	</font></td>
                        <td nowrap width="30"  bgcolor = "#336699"	align="center"><font color="white"> Busy Min.</font></td>
                        <td nowrap width="100" bgcolor = "#336699"	align="center"><font color="white"> Write Time </font></td>
                        <td nowrap width="100" bgcolor = "#336699"	align="center"><font color="white"> Link seq		</font></td>
                    </tr>


            <%
                SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy");
                SimpleDateFormat monthFormat = new SimpleDateFormat("MM");
                SimpleDateFormat dayFormat = new SimpleDateFormat("dd");

                SimpleDateFormat hourFormat = new SimpleDateFormat("HH");
                SimpleDateFormat minuteFormat = new SimpleDateFormat("mm");
                SimpleDateFormat secondFormat = new SimpleDateFormat("ss");

                String bgColor = null;
                String packetColor = null;

                for (int i = 0; i < tempLogQueryVoList.size(); i++) {
                    TempLogQueryVo tempLogQueryVo = tempLogQueryVoList.get(i);

                    String myNumber = tempLogQueryVo.getMyNumber();
                    String myName = tempLogQueryVo.getMyName();
                    String yourNumber = tempLogQueryVo.getYourNumber();
                    String yourName = tempLogQueryVo.getYourName();
                    int sequence = tempLogQueryVo.getSequence();
                    String status = tempLogQueryVo.getStatus();
                    String checkNumber = tempLogQueryVo.getCheckNumber();
                    String packetData = tempLogQueryVo.getPacketData();
                    long busyMinute = tempLogQueryVo.getBusyMinute();

                    String year = yearFormat.format(tempLogQueryVo.getWriteTime());
                    String month = monthFormat.format(tempLogQueryVo.getWriteTime());
                    String day = dayFormat.format(tempLogQueryVo.getWriteTime());
                    String hour = hourFormat.format(tempLogQueryVo.getWriteTime());
                    String minute = minuteFormat.format(tempLogQueryVo.getWriteTime());
                    String second = secondFormat.format(tempLogQueryVo.getWriteTime());
                    String writeTimeString = year + "." + month + "." + day + "\t" + hour + ":" + minute + ":" + second;

                    int linkSequence = tempLogQueryVo.getLinkSequence();

                    if ( status.equals("NLN") ) {
                        bgColor = "#55CC11";
                    } else if ( status.equals("FLN") ) {
                        bgColor = "#FF3333";
                    } else if ( status.equals("BSY") ) {
                        bgColor = "#FF9922";
                    } else {
                        bgColor = "#D4D4D4";
                    }


                    if ( packetData.substring(0, 2).equals("Soc") ) {
                        packetColor = "#77AAFF";
                    } else if ( packetData.substring(0, 2).equals("CHG") && packetData.substring(6, 8).equals("NLN") ) {
                        packetColor = "#55CC11";
                    } else if ( packetData.substring(0, 2).equals("CHG") && packetData.substring(6, 8).equals("FLN") ) {
                        packetColor = "#FF3333";
                    } else if ( packetData.substring(0, 2).equals("CHG") && packetData.substring(6, 8).equals("BSY") ) {
                        packetColor = "#FF9922";
                    } else {
                        packetColor = "#FFFFFF";
                    }

            %>

                    <tr>
                        <td nowrap  bgcolor="#FFFFFF" align="center"><%=sequence%></td>
                        <td nowrap  bgcolor="#FFFFFF" align="center"><b><%=myName%></b><br/><%=myNumber%></td>
                        <td nowrap  bgcolor="#FFFFFF" align="center"><b><%=yourName%></b><br/><%=yourNumber%></td>
                        <td nowrap  bgcolor="<%=bgColor%>" align="center"> 		<%=status%>		</td>
                        <td nowrap  bgcolor="#FFFFFF" align="center"><%=checkNumber%></td>
                        <td nowrap  bgcolor=<%=packetColor%>  align="left">&nbsp;<%=packetData%>	</td>
                        <td nowrap  bgcolor="#FFFFFF" align="center"> 				<%=busyMinute%>		</td>
                        <td nowrap width="90" nowrap height="30" bgcolor="#FFFFFF" align="center"><%=writeTimeString%>	</td>
                        <td nowrap bgcolor="#FFFFFF" align="center"> 				<%=linkSequence%>		</td>
                    </tr>

<%
                }
%>
                </table>

                <br/>

                <br/>

 <%
        if (friendStateList != null && friendStateList.size() > 0) {      // 1111
 %>
            <table  border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
                <tr>
                <h5>The recent statement of friends that are not received my notification.</h5>
                </tr>
                    <tr>
                        <td nowrap width="40" 	bgcolor = "#336699" align="center"><font color="white">seq</font></td>
                        <td nowrap width="130" bgcolor = "#336699" align="center"><font color="white"> Owner </font></td>
                        <td nowrap width="130" bgcolor = "#336699" align="center"><font color="white"> Friend	</font></td>
                        <td nowrap width="40" 	bgcolor = "#336699" align="center"><font color="white"> Status 	</font></td>
                        <td nowrap width="40"  bgcolor = "#336699"	align="center"><font color="white"> Check Number </font></td>
                        <td nowrap width="200" bgcolor = "#336699" align="center"><font color="white"> Packet Data 	</font></td>
                        <td nowrap width="30"  bgcolor = "#336699"	align="center"><font color="white"> Busy Min.</font></td>
                        <td nowrap width="100" bgcolor = "#336699"	align="center"><font color="white"> Write Time </font></td>
                        <td nowrap width="100" bgcolor = "#336699"	align="center"><font color="white"> Link seq		</font></td>
                    </tr>
            <%
                for (int i = 0; i < friendStateList.size(); i++) {
                    TempLogQueryVo tempLogQueryVo = friendStateList.get(i);

                    String myNumber = tempLogQueryVo.getMyNumber();
                    String myName = tempLogQueryVo.getMyName();
                    String yourNumber = tempLogQueryVo.getYourNumber();
                    String yourName = tempLogQueryVo.getYourName();
                    int sequence = tempLogQueryVo.getSequence();
                    String status = tempLogQueryVo.getStatus();
                    String checkNumber = tempLogQueryVo.getCheckNumber();
                    String packetData = tempLogQueryVo.getPacketData();
                    long busyMinute = tempLogQueryVo.getBusyMinute();

                    String year = yearFormat.format(tempLogQueryVo.getWriteTime());
                    String month = monthFormat.format(tempLogQueryVo.getWriteTime());
                    String day = dayFormat.format(tempLogQueryVo.getWriteTime());
                    String hour = hourFormat.format(tempLogQueryVo.getWriteTime());
                    String minute = minuteFormat.format(tempLogQueryVo.getWriteTime());
                    String second = secondFormat.format(tempLogQueryVo.getWriteTime());
                    String writeTimeString = year + "." + month + "." + day + "\t" + hour + ":" + minute + ":" + second;

                    int linkSequence = tempLogQueryVo.getLinkSequence();

                    if ( status.equals("NLN") ) {
                        bgColor = "#55CC11";
                    } else if ( status.equals("FLN") ) {
                        bgColor = "#FF3333";
                    } else if ( status.equals("BSY") ) {
                        bgColor = "#FF9922";
                    } else {
                        bgColor = "#D4D4D4";
                    }


                    if ( packetData.substring(0, 2).equals("Soc") ) {
                        packetColor = "#77AAFF";
                    } else if ( packetData.substring(0, 2).equals("CHG") && packetData.substring(6, 8).equals("NLN") ) {
                        packetColor = "#55CC11";
                    } else if ( packetData.substring(0, 2).equals("CHG") && packetData.substring(6, 8).equals("FLN") ) {
                        packetColor = "#FF3333";
                    } else if ( packetData.substring(0, 2).equals("CHG") && packetData.substring(6, 8).equals("BSY") ) {
                        packetColor = "#FF9922";
                    } else {
                        packetColor = "#FFFFFF";
                    }

            %>

                    <tr>
                        <td nowrap  bgcolor="#FFFFFF" align="center"><%=sequence%></td>
                        <td nowrap  bgcolor="#FFFFFF" align="center"><b><%=myName%></b><br/><%=myNumber%></td>
                        <td nowrap  bgcolor="#FFFFFF" align="center"><b><%=yourName%></b><br/><%=yourNumber%></td>
                        <td nowrap  bgcolor="<%=bgColor%>" align="center"> 		<%=status%>		</td>
                        <td nowrap  bgcolor="#FFFFFF" align="center"><%=checkNumber%></td>
                        <td nowrap  bgcolor=<%=packetColor%>  align="left">&nbsp;<%=packetData%>	</td>
                        <td nowrap  bgcolor="#FFFFFF" align="center"> 				<%=busyMinute%>		</td>
                        <td nowrap width="90" nowrap height="30" bgcolor="#FFFFFF" align="center"><%=writeTimeString%>	</td>
                        <td nowrap bgcolor="#FFFFFF" align="center"> 				<%=linkSequence%>		</td>
                    </tr>

<%
                }
%>
                </table>

                <br/>

                <br/>

 <%
        }       // 1111
 %>

                <%
                }
                %>

</FORM>

            </div>

        </div>
    </body>

</HTML>
